package com.zHan.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zHan.pojo.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class IBookDaoTestCase {

    @Autowired
    private IBookDao bookDao;

    // 查询所有
    @Test
    void testSelectAll(){
        bookDao.selectList(null);
    }

    // 分页查询
    @Test
    void testPage(){
        IPage page=new Page(1,5);
        bookDao.selectPage(page,null);
    }

    // 条件查询
    @Test
    void testSelectBy(){
//        String name="spring";
        String name=null;
        LambdaQueryWrapper<Book> wrapper=new LambdaQueryWrapper<>();
        wrapper.like(name!=null,Book::getName,name);
        bookDao.selectList(wrapper);
    }
}
